package V003_MapLoader;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.Toolkit;

/**
 *
 * @author Smai
 *
 * positionInWorldX - tietää missä kohtaa taulukkoa tile sijaitsee
 * positionInWorldY
 *
 * width - Olion leveys
 * height - Olion korkeus
 *
 * collision - Onko olio este
 * texture - Olion texturi
 * image - kuva
 */
public class Tile {

  Toolkit toolkit = Toolkit.getDefaultToolkit();
  private int positionInWorldArrayX;
  private int positionInWorldArrayY;
  private int focusPosX;
  private int focusPosY;
  private int width;
  private int height;
  private String type;
  private String info;
  private boolean collision;
  private Image image;

  //X,Y,Width,Height,Type,Info,Collision
  public Tile(int x, int y, int width, int height, String type, String info, boolean collision) {
    this.positionInWorldArrayX = x;
    this.positionInWorldArrayY = y;
    this.width = width;
    this.height = height;
    this.type = type;
    this.info = info;
    this.collision = collision;

    image = toolkit.getImage("Resources//Textures//" + type + ".png");
  }

  public void paint(Graphics gbi, int i, int j, int focusPosX, int focusPosY) {
    positionInWorldArrayX = i;
    positionInWorldArrayY = j;
    this.focusPosX = focusPosX;
    this.focusPosY = focusPosY;
    gbi.drawImage(image, (-32) + (positionInWorldArrayX * 32) - this.focusPosX,
            (-32) + (positionInWorldArrayY * 32) - this.focusPosY, null);

  }

  public Rectangle getRectangle() {
    if (collision) {
      return (new Rectangle((-32) + (positionInWorldArrayX * 32) - this.focusPosX,
              (-32) + (positionInWorldArrayY * 32) - this.focusPosY, width, height));
    } else {
      return null;
    }


  }

  public String getOnko(){
    return "x";
  }
}
